package us.kg.kotoriforest.spring.service.impl;

import lombok.Getter;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.EnvironmentAware;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import us.kg.kotoriforest.spring.dao.UserDao;
import us.kg.kotoriforest.spring.service.UserService;

/**
 * @author Kotori rotroutine@163.com
 * @since 2025/1/24
 */
@Service
@Getter
public class UserServiceImpl implements UserService, BeanNameAware, EnvironmentAware {
    // @Autowired自动装配首先按照类型进行装配，如果发现类型有多个，再按照名称进行装配
    @Autowired
    private UserDao userDao;
    private String beanName;
    private Environment environment;

    @Override
    public void setBeanName(String name) {
        this.beanName = name;
        System.out.println("bean name is " + name);
    }

    @Override
    public void setEnvironment(Environment environment) {
        this.environment = environment;
    }
}
